﻿Public Class Form8

    Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
        PictureBox1.ImageLocation = "http://avatar.xboxlive.com/avatar/" + TextBox1.Text + "/avatar-body.png"
        PictureBox2.ImageLocation = "http://avatar.xboxlive.com/avatar/" + TextBox1.Text + "/avatarpic-l.png"
    End Sub

    Private Sub ButtonX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX2.Click
        Try
            Dim SaveFileDialog1 As New SaveFileDialog
            SaveFileDialog1.Title = "Save Avatar As..."
            SaveFileDialog1.Filter = "PNG|.png|JPEG|*.jpg|GIF|*.gif"
            If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim ImageFormatToUse As Imaging.ImageFormat = Imaging.ImageFormat.Png
                If SaveFileDialog1.FilterIndex = 0 Then ImageFormatToUse = Imaging.ImageFormat.Png
                If SaveFileDialog1.FilterIndex = 1 Then ImageFormatToUse = Imaging.ImageFormat.Jpeg
                If SaveFileDialog1.FilterIndex = 2 Then ImageFormatToUse = Imaging.ImageFormat.Gif
                PictureBox1.Image.Save(SaveFileDialog1.FileName, ImageFormatToUse)
            End If
        Catch ex As Exception
        End Try
    End Sub
End Class